package org.blogspot.t0yv0.marcalog.model

import javax.jdo._
import org.blogspot.t0yv0.marcalog.util._

object Data {

  private val factory =
    JDOHelper.getPersistenceManagerFactory("transactions-optional");

  def connect[T](f: DataManager => T) : T = {
    val manager = new DataManager(factory.getPersistenceManager);
    try {
      f(manager);
    } finally {
      manager.close;
    }
  }

}
